/**
 @file sys_usw_stats_api.h

 @date 2009-12-15

 @version v2.0

*/
#ifndef _SYS_USW_STATS_API_H
#define _SYS_USW_STATS_API_H
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************
 *
 * Header Files
 *
 ***************************************************************/
#include "ctc_const.h"
#include "ctc_macro.h"
#include "ctc_stats.h"
#include "sys_usw_api.h"

#define SYS_STATS_IPE_DISCARD_TYPE_START            0x1
#define SYS_STATS_IPE_DISCARD_TYPE_END              0x40
#define SYS_STATS_IPE_DISCARD_TYPE_MAX              (SYS_STATS_IPE_DISCARD_TYPE_END - SYS_STATS_IPE_DISCARD_TYPE_START + 1)
#define SYS_STATS_EPE_DISCARD_TYPE_START            0x41
#define SYS_STATS_EPE_DISCARD_TYPE_END              0x78
#define SYS_STATS_EPE_DISCARD_TYPE_MAX              (SYS_STATS_EPE_DISCARD_TYPE_END - SYS_STATS_EPE_DISCARD_TYPE_START + 1)
#define SYS_STATS_DISCARD_TYPE_MAX                  ((SYS_STATS_IPE_DISCARD_TYPE_MAX >= SYS_STATS_EPE_DISCARD_TYPE_MAX) ? SYS_STATS_IPE_DISCARD_TYPE_MAX: SYS_STATS_EPE_DISCARD_TYPE_MAX)


/*policing storage structor*/
struct sys_stats_policing_s
{
    uint64 policing_confirm_pkts;
    uint64 policing_confirm_bytes;
    uint64 policing_exceed_pkts;
    uint64 policing_exceed_bytes;
    uint64 policing_violate_pkts;
    uint64 policing_violate_bytes;
};
typedef struct sys_stats_policing_s sys_stats_policing_t;

/*queue storage structor*/
struct sys_stats_queue_s
{
    uint64 packets;
    uint64 bytes;
};
typedef struct sys_stats_queue_s sys_stats_queue_t;

/***************************************************************
 *
 *  flow stats api
 *
 ***************************************************************/
extern int32
sys_usw_flow_stats_ram_assign(uint8 lchip, uint16 ram_bmp[][CTC_BOTH_DIRECTION], uint32 acl_ram_bmp[][CTC_BOTH_DIRECTION], uint32 scl_ram_bmp[][CTC_BOTH_DIRECTION]);
extern int32
sys_usw_flow_stats_init(uint8 lchip, ctc_stats_global_cfg_t* stats_global_cfg);
extern int32
sys_usw_flow_stats_deinit(uint8 lchip);
extern int32
sys_usw_flow_stats_set_drop_packet_stats_en(uint8 lchip, ctc_stats_discard_t bitmap, bool enable);
extern int32
sys_usw_flow_stats_get_drop_packet_stats_en(uint8 lchip, ctc_stats_discard_t bitmap, bool* enable);
extern int32
sys_usw_flow_stats_enable_igs_port_discard_stats(uint8 lchip, uint8 enable);
extern int32
sys_usw_flow_stats_clear_igs_port_discard_stats(uint8 lchip, uint32 gport);
extern int32
sys_usw_flow_stats_enable_egs_port_discard_stats(uint8 lchip, uint8 enable);
extern int32
sys_usw_flow_stats_get_egs_port_discard_stats(uint8 lchip, uint32 gport, ctc_stats_basic_t* p_stats);
extern int32
sys_usw_flow_stats_clear_egs_port_discard_stats(uint8 lchip, uint32 gport);
extern int32
sys_usw_flow_stats_alloc_statsptr(uint8 lchip, sys_stats_param_t* p_sts);
extern int32
sys_usw_flow_stats_free_statsptr(uint8 lchip, sys_stats_param_t* p_sts);
extern int32
sys_usw_flow_stats_restore_statsptr(uint8 lchip, uint8 stats_num, uint8 dir, uint8 stats_type, uint32 stats_ptr );

extern int32
sys_usw_flow_stats_get_queue_stats2(uint8 lchip, uint32 gport, uint16 queue_id, ctc_qos_queue_stats_info_t* p_stats);
extern int32
sys_usw_flow_stats_sync_queue_stats(uint8 lchip, uint32 stats_ptr1, uint32 stats_ptr2);
extern int32
sys_usw_flow_stats_set_saturate_en(uint8 lchip, ctc_stats_type_t stats_type, bool enable);
extern int32
sys_usw_flow_stats_get_saturate_en(uint8 lchip, ctc_stats_type_t stats_type, bool* p_enable);
extern int32
sys_usw_flow_stats_set_keep_mode(uint8 lchip, ctc_stats_type_t stats_type, bool enable);
extern int32
sys_usw_flow_stats_get_keep_mode(uint8 lchip, ctc_stats_type_t stats_type, bool* p_enable);
extern int32
sys_usw_flow_stats_set_hold_en(uint8 lchip, ctc_stats_type_t stats_type, bool enable);
extern int32
sys_usw_flow_stats_get_hold_en(uint8 lchip, ctc_stats_type_t stats_type, bool* p_enable);
extern int32
sys_usw_flow_stats_set_clear_after_read_en(uint8 lchip, ctc_stats_type_t stats_type, bool enable);
extern int32
sys_usw_flow_stats_get_clear_after_read_en(uint8 lchip, ctc_stats_type_t stats_type, bool* p_enable);
extern int32
sys_usw_flow_stats_set_pkt_cnt_threashold(uint8 lchip, ctc_stats_type_t stats_type, uint16 value);
extern int32
sys_usw_flow_stats_get_pkt_cnt_threashold(uint8 lchip, ctc_stats_type_t stats_type, uint16* value);
extern int32
sys_usw_flow_stats_set_byte_cnt_threashold(uint8 lchip, ctc_stats_type_t stats_type, uint16 value);
extern int32
sys_usw_flow_stats_get_byte_cnt_threashold(uint8 lchip, ctc_stats_type_t stats_type, uint16* value);
extern int32
sys_usw_flow_stats_set_fifo_interrupt_threashold(uint8 lchip, ctc_stats_type_t stats_type, uint8 value);
extern int32
sys_usw_flow_stats_get_fifo_interrupt_threashold(uint8 lchip, ctc_stats_type_t stats_type, uint8* value);
extern int32
sys_usw_flow_stats_get_statsptr(uint8 lchip, uint32 stats_id, uint32* p_cache_ptr);

extern int32
sys_usw_flow_stats_create_statsid(uint8 lchip, ctc_stats_statsid_t* statsid);
extern int32
sys_usw_flow_stats_destroy_statsid(uint8 lchip, uint32 stats_id);
extern int32
sys_usw_flow_stats_lookup_statsid(uint8 lchip, ctc_stats_statsid_type_t type, uint32 stats_ptr, uint32* p_statsid, uint8 dir);
extern int32
sys_usw_flow_stats_get_stats(uint8 lchip, sys_stats_param_t* p_st, ctc_stats_basic_t* p_stats);
extern int32
sys_usw_flow_stats_clear_stats(uint8 lchip, sys_stats_param_t* p_st);
extern int32
sys_usw_flow_stats_get_statsid(uint8 lchip, sys_stats_statsid_t* p_statsid);

extern int32
sys_usw_flow_stats_get_table_id(uint8 lchip, uint8 ram_idx, uint32* table_id);
extern int32
sys_usw_flow_stats_get_mem_usage(uint8 lchip, ctc_stats_mem_usage_t* p_status);
extern int32
sys_usw_flow_stats_get_stats_type_pp_en(uint8 lchip, ctc_stats_statsid_t* p_ctc_statsid, uint8* pp_en);
extern int32
sys_usw_flow_stats_get_stats_type_pp_en_by_stats_id(uint8 lchip, uint32 stats_id, uint8* pp_en);
extern int32
sys_usw_flow_stats_get_ram_info(uint8 lchip, uint8 blkid, uint32* offset, uint32* total);
extern int32
sys_usw_flow_stats_alloc_fid_type(uint8 lchip);
/***************************************************************
 *
 *  mac stats api
 *
 ***************************************************************/
extern int32
sys_usw_mac_stats_init(uint8 lchip, ctc_stats_global_cfg_t* stats_global_cfg);
extern int32
sys_usw_mac_stats_deinit(uint8 lchip);
extern int32
sys_usw_mac_stats_set_property_mtu1(uint8 lchip, uint32 gport, uint16 length);
extern int32
sys_usw_mac_stats_get_property_mtu1(uint8 lchip, uint32 gport, uint16* p_length);
extern int32
sys_usw_mac_stats_set_property_mtu2(uint8 lchip, uint32 gport, uint16 length);
extern int32
sys_usw_mac_stats_get_property_mtu2(uint8 lchip, uint32 gport, uint16* p_length);
extern int32
sys_usw_mac_stats_set_property_pfc(uint8 lchip, uint32 gport, uint8 enable);
extern int32
sys_usw_mac_stats_get_property_pfc(uint8 lchip, uint32 gport, uint8* p_enable);
extern int32
sys_usw_mac_stats_set_global_property_hold(uint8 lchip, bool enable);
extern int32
sys_usw_mac_stats_get_global_property_hold(uint8 lchip, bool* p_enable);
extern int32
sys_usw_mac_stats_set_global_property_saturate(uint8 lchip, bool enable);
extern int32
sys_usw_mac_stats_get_global_property_saturate(uint8 lchip, bool* p_enable);
extern int32
sys_usw_mac_stats_set_global_property_clear_after_read(uint8 lchip, bool enable);
extern int32
sys_usw_mac_stats_get_global_property_clear_after_read(uint8 lchip, bool* p_enable);
extern int32
sys_usw_mac_stats_get_rx_stats(uint8 lchip, uint32 gport, ctc_mac_stats_t* p_stats);
extern int32
sys_usw_mac_stats_clear_rx_stats(uint8 lchip, uint32 gport);
extern int32
sys_usw_mac_stats_get_tx_stats(uint8 lchip, uint32 gport, ctc_mac_stats_t* p_stats);
extern int32
sys_usw_mac_stats_clear_tx_stats(uint8 lchip, uint32 gport);
extern void
sys_usw_mac_stats_get_port_rate(uint8 lchip, uint32 gport, uint64* p_throughput);
#ifdef __cplusplus
}
#endif

#endif

